Best practice for loading initial data into a backbone app? [closed] - javascript

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I understand from the Backbone docs it is best practice to bootstrap model data into the application by embedding it in script tags that render on the initial page load.
I realize that this is done to avoid sending extra requests to the server, which will speed up page load.
But...
Does it really make that big of a difference? I am currently calling fetch on a half-dozen models and collections on page-load, and everything seems to load very quickly.
Are there any other reasons for using this suggested method of bootstrapping data? If not, it seems like extra effort for negligible gains, to me.

Maybe it's fast on your development machine with just you as the user (you didn't specify the environment), but when you have many more users those requests can begin to add up. In that case, if you can bootstrap some of the data then the benefits can become more apparent. Try using chrome inspector's network monitoring pane to get more detailed information on the difference between the two methods.

Related

Ajax+eval more harmful than script tag? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am building an application where I load scripts on the go:
var newScript=document.createElement("script");
newScript.src="script.js";
document.head.appendChild(newScript);
The scripts are in the same domain, so rather than using a script tag I am considering using ajax+eval as it gives me more flexibility (in particular to synchronize with other scripts). Are both options equivalent, or is there any additional risk when using eval?
With regards to risk, both are equivalent.
Both methods execute the downloaded script blindly (without checking). The only difference is that you can't execute script from other domains with ajax.
On the other hand, by downloading the script as text before evaling it you have the chance to run some text processing on it such as checking for known malicious attacks, linting it etc. So you could, in theory, build a secure and/or restricted execution environment by using ajax+eval. But figuring out what is malicious and what is benign is not easy.
One of the only legit uses for eval is when your AJAX call is returning JavaScript. While this does give additional flexibility. I'm not sure about your particular app, but these are the main concerns:
Users can send any data they want through AJAX. Make sure your server-side code is clean.
AJAXing scripts means that the browser can't cache them. This'll result in a slower user experience.

What are the best chart/graph js plugins? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm trying to find a smart way to display data on my dashboard page. What are the nicest and most flexible resources to plot charts and graphs?
First determine if you want to use an hosted solution like google charts, or you want more control and need a library you want to host yourself. Hosted solutions are very convenient and integrate fairly quickly, but your data is inherently exposed to the outside world. If you're building a corporate site this can be a "no go".
Also think if you want a client side or server side solution. I personally would go for a client side library if you don't have a huge amount of data that needs to be visualized. Client side libraries very often are more flexible (think: animation, resizing, etc)
I have used highcharts. It is very powerful, and has many types of graphs, but it can be hard to find the setting that you need to get the exact effect that you want. Not because the documentation is bad (which it isn't), but because there are so many options.
How about Google Charts?
Try Visualize. I like it, because it's fully accessible :).

Routing library for Javascript? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I used to use Backbone.js as an easy MVC framework which have build-in routing support. Now I have moved and currently using Agility.js which doesn't routing support. So my question is, is there any alternative to Backbones.js's routing?
For reference on why I need this is because my "style" of writing is a one-page website that query the server for information.
I've faced the same question just some weeks ago and wrote "Simrou", a very basic framework that does nothing but this kind of routing (hash-based). You can define the routes in Backbone's own style and then attach action handlers to GET, POST, PUT etc. requests (GET is basically a clicked link, POST etc. can be triggered by forms).
https://github.com/buero-fuer-ideen/Simrou
Not sure what sort of features you are looking for, but I just put up an extremely lightweight JS router that offers the bare minimum to get things going. A lot of the routers I had come across were offering way more features than I was looking for, so I thought this might help fill a void for those looking for something light. It defaults to use pushState, falls back to hash. http://gabehayes.github.com/lennonjs/.
Another option is Davis.js it provides simple routing, based on pushState (it can work with hash based routing also). It is inspired by Sammy.js but only focuses on the routing side.

How to create a web crawler with Node.js? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I just recently got interested in how search engines work, and I found out that they use "bots" or "webcrawlers". I immediately started wondering about how do these things work and I wanted to create one! So, first of: how do you make a program that requests a page from a server? It would be awesome if you gave me a simple example in JavaScript (I'm running it as a normal scripting language using Node). Next, is there a Node module that let's me interpret HTML? Create a DOM for me so I can cycle trough all the links and so on? Correct me if I'm wrong but I guess it's done like that... Any examples in C++, C or Python are warmly welcomed as well, although I'd prefer JS or Python because I'm more familiar with high-level scripting languages.
Getting HTTP pages: node http.get (example is there)
DOM documents: jsdom (also includes examples)

What is most popular ajax framework for modern days? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
If I'm developing a client side application with heavy load, what is the most appropriate choice of Ajax framework?
I'd recommend you the JQuery. It is not just an ajax framework, it is more than that.
Client side? jQuery. Server side? Depends on your environment. Also, AJAX is not a framework per definition, but there are various libraries like jQuery which will ease the pain when using AJAX.
AJAX exists just to send some data and recieve some data from your server or some other site without forcing you to do a whole page reload. That's all about it in the nutshell.
If you're looking for a technology that will automatically place widgets on your site that use AJAX, that's a whole different story...

Categories