Tag Info

Hot answers tagged

29

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


17

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


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

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

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.


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


4

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


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

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


3

Well, I would test all major browsers and their older version (IE7, IE8, etc.) and I would note those that don't seem to best render your website. Then, I will simply write a piece of code that would only show browser recommendation for those that fall in the category of browser that don't render the pages appropriatly. I also believe that suggesting to ...


3

A script has no actual use until the HTML has finished loading - a script can’t change the DOM until the HTML has loaded. document.ready waits for the DOM to load. So, there's no point it holding up important things like stylesheets. Put the scripts at the bottom of the page (before the </body> tag) to order to get your HTML and CSS to the user as ...


3

The reasons I use jQuery over any other library: Fast and Lightweight jQuery continues to increase the performance of their library even in of minor-revision-level releases. When they released 1.4.2, the speed of the library was greatly increased even from 1.4.1, as shown in an Ajaxian blog post regarding its release. Performance analysis of 1.4 compared to ...


3

It's not a single page. (This should be obvious just from viewing source.) There are separate documents, like this one, being loaded via Ajax. In Firefox, open Firebug and enable the Net tab. When you click the navigation links, you'll be able to see the GET requests for them.


3

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



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