Tag Info

Hot answers tagged

30

Document.ready waits for the DOM to load before running any JavaScript (http://www.learningjquery.com/2006/09/introducing-document-ready). The idea of putting it at the bottom, means that if your JS is having issues or the person has a slow connection, the rest of the page still loads first, and doesn't "hang". The JS still runs when everything has loaded, ...


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. ...


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 ...


12

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 ...


11

jQuery is client-side, so it operates independently of server. Your hosting environment shouldn't really have any effect on how jQuery works (Unless you're doing something unique with AJAX or some other type of JavaScript that interacts with the server) Languages such as PHP (The language scripts such as WordPress, Drupal and Joomla! are programmed in), ...


10

A browser recommendation is usually a Do Not Enter sign. Unless you have an extremely popular service with unique features, it is extremely unlikely that people will change browsers for you. Therefore they are highly likely to simply leave. This does not mean you have to write code that works perfectly for every browser. In a support page somewhere you can ...


10

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


8

Nothing against prototype but it does not have the amount of plug-ins or nearly as large of a community as jQuery does. For jQuery there is already a plug-in for almost anything, so I end up writing a lot less js.


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 ...


7

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 ...


6

Putting javascript at the bottom means that the other page content (text especially) loads before the javascript so users are not waiting for the JS to load if they have slow connections. This does not affect document.ready, as that is called when the browser has finished preparing the DOM for a page. Either way, everything still needs to be loaded first.


6

It's mostly a matter of preference. Some people don't like how Prototype extends objects, but for basic use they are fairly equivalent. Prototype is still in active development - they put out a release candidate for the next release just a couple months ago.


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 ...


6

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.


5

Actually, Spidermonkey (FF) and V8 (Chrome) are very similar in the core javascript engine API in that both try to be standards compliant. The main difference is that Spidermonkey tends to add some nice extras to their API if they feel it is needed. All of this is found at the Mozilla Development Center (MDC) for JavaScript and well documented if it is not ...


5

No, links inserted with Javascript will not be crawlable. You are better using a server-side solution to add links, i.e. output <a href="link">etc</a> direct in your HTML. Having said that, search engines are always improving. Google recently announced major improvements to the crawling of Flash files, so it's not impossible that some Javascript ...


5

Just keep your content fresh and relevant. If your navigation needs an update, change it to be clearer and more useful to your visitors. Don't try to fool search engines by hiding text, through any means. Google doesn't publish their ranking criteria, but they do offer this guide.


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

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

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 ...


5

https://github.com/balupton/history.js/wiki/Intelligent-State-Handling ^ Goes into the pros AND CONS of hashed and hasbhangs URLs and provides alternative solutions


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 - ...


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

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

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 ...



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