Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Hot answers tagged

55

If you serve jQuery from a popular CDN such as Google's Hosted Libraries or cdnjs, it won't be redownloaded if your visitor has been on a site that referenced it from the same source (as long as the cached version has not expired). jQuery is a popular library, just as you say, but bundling it with the browser is not likely to happen for a few reasons: ...


21

Not only is jQuery not the only popular JS library, a browser would potentially have to include multiple versions. The Google CDN currently lists: 42 versions of jQuery; 44 versions of jQuery UI; 6 versions of jQuery Mobile. It's better to allow web developers to define which version of a library to download based on their website's requirements. If you use ...


18

There are two major benefits to using an external CDN such as Google to host jQuery: It's faster. It will be certainly be faster than your site, and probably faster than any CDN you set up yourself. It may already be cached. Lots of sites reference jQuery on Google's CDN as well, so if they visited another site with it before yours, they won't even need to ...


14

None of them. It will not be indexed (only in obscure odd cases). Minifying JS is about loading speed and obfuscating JS is for making it harder for other developers to read your code. Google does however rank your website based on load speed, and if you are including 15 JavaScript files and 20 stylesheets, your site gets slow and therefore loses rank. ...


14

The browser is the engine it isn't the engine designer's duty to find out what kind of fuel and extra parts are you going to put into your car and include it for you. If they would do this browsers would be a huge bloatware because the next question will be "why just jQuery?", and we would end up maintaining dependency repositories. Also, will we include ...


13

Sure. Obviously, it would be better to use CSS alone but if you can't, use what you have. Do as much as you can with CSS and use JS as needed. Not sure why you can't change the existing CSS but you can add a style sheet with JS. (function() { //create a new element var newStyle = document.createElement("link"); //set the required attribute for a ...


12

It is quite common, and for high traffic websites certainly using a Content Delivery Network is sound advice, it takes the strain off your main server whilst making sure users get static content quickly. There is the added benefit that if I visit site A that uses say the Google hosted jQuery and then visit site B that does the same, I will have cached it ...


11

Another downside: Using a CDN allows operator of the CDN to track the sites visitors. That's why they don't cost money.


9

It's impossible to prevent your Javascript from being "stolen" because the code is served to the browser. To answer your specific points: 1. I have disabled the right click button of mouse This will have absolutely no effect. No one will ever try to steal code using right click (heck, right click doesn't give access to anything in a browser anyway). So ...


8

If your framework/CMS/whatever has the appropriate functions, you can include the scripting conditionally as @Michael suggests, but without the additional library. Taking your datatables case, for example, WordPress might handle the situation via something like: // For reference; this isn't functional code. if (is_page('whatever')) { <script src="/...


8

I have disabled the right click button of mouse Don't do this. There are valid uses for right-click that you are blocking in addition to (not) protecting your code. All you'll do is annoy everybody while doing absolutely nothing to stop the people who know enough to try and steal your code in the first place.


6

I was looking for the same thing and came across this... http://caroufredsel.frebsite.nl/examples/variable-visible-variable-size.php - it was the easiest to use and fully customizable. Not sure if you found what you were looking for already, but just in case someone else is looking for the same thing - it may help.


6

You can use requirejs to dynamically load the libraries you need only on that pages. Then you only have to load the requirejs (which is about 14k) on all pages, saving about 385kb. Integration is also very easy: just "wrap" the code you have with the require include stuff: require(["jquery", "jquery.alpha", "jquery.beta"], function($) { //the jquery....


5

Check BuiltWith.com's Web Technology Trends & HTTPArchive website's stats for metrics on usage of external libraries & services. As per BuiltWith.com, 2,146,587 websites use Google's AJAX Libraries API. This includes 169,454 websites within the most visited sites on the internet and an additional 1,977,133 websites on the rest of the web. ...


5

Here is a slider which has auto-height capability and auto-width http://webbies.dk/SudoSlider/demos.html Demo http://webbies.dk/SudoSlider/assets/files/SudoSlider/package/demos/autoheight.html This also has auto-height capability http://slidesjs.com/ See the autoHeight option


5

ProgrammableWeb tracks web APIs & it shows a useful list when you search with the keyword "dictionary" FOLDOC.org & WordNet from Princeton University provide their dictionary database for free. Customizing the database will require some programming.


5

While Christopher's answer is somewhat correct, many times you won't want to use a tracepoint that interrupts execution and requires manual interaction to resume execution (at that point it's technically a breakpoint). With Firebug or equivalent browser debug consoles, you can insert tracepoints into your code using console.log(). AFAIK, the console object ...


5

700kb of JavaScript IS a performance issue, because it must be parsed after page load. Because of it, you should take care, that only those scripts, that are needed, are loaded. One big JavaScript may be OK on full AJAX sites, such as GMail, when the navigation is handled internally without leaving the single page. However, even full AJAX sites do dynamic JS ...


4

There quite a lot of jQuery powered sliders that can do such job. Here are just a few that should fall under your requirements (I'm just not 100% sure on "constantly right to left" requirement -- if fade in/out (or similar effects) counts as "right to left" the it will be fine): Nivo Slider - http://nivo.dev7studios.com/ FlexSkuder - http://flex....


4

This is a fairly standard feature, at least among the well-known options. (To the point that they generally don't bother making too much mention of it.) It doesn't seem like it'd be hard to find one unless you're looking for something more. Anyway: Shadowbox, with the handleOversize argument fancyBox, with the fitToView argument Colorbox takes a different ...


4

View source. It's Paul Irish's Infinite Scroll jQuery plugin, for WordPress.


4

Since November 2011 The Googlebot has been able to read AJAX/javascript content, facebook, Google+ and twitter content etc. Since Matt Cutts specifically mentioned comments in his tweet I believe your content will get indexed. Matt Cutts of Google Tweeted yesterday that “Google can now execute AJAX/JavaScript to index some dynamic comments.” which means ...


4

It's called "The Catfish". Sitepoint wrote an article about doing it a long time ago but I'm sure it's still effective today.


4

If you want to know when the page has fully loaded, then you need to use the window.onload (or $(window).load()) event, not jQuery's $(document).ready() event. $(document).ready() is triggered as soon as the HTML document has finished downloading and the DOM is ready. But the images and other resources aren't done loading at this point. If you want to know ...


4

I would say try using media queries first. One method I found easier when dealing with a design that was originally only for desktop was this: Start with two separate stylesheets. One for the new responsive design, and the other for the old desktop version: <link rel="stylesheet" media="screen and (max-width: 959px)" href="css/mobile.css"> <link ...


4

Remove "http:" from the script src url, like: <script src="//code.jquery.com/jquery-2.1.4.min.js"> In case the problem insists, check if shows errors through Chrome Dev Console and paste it here.


3

SlidesJS is less than 7kb minified and works pretty well. It does simple slide and supports links. Not sure about the CSS3/Animate requirement.


3

Yes, you should combine the files. Just use the custom download builder to select the parts you need, and it'll do it for you.


3

If you can view the content of those tabs in the source code then it will be indexed by the search engines and will be indexed.


Only top voted, non community-wiki answers of a minimum length are eligible