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

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


11

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


10

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

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.


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

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


4

Folder and File Permissions and Ownership It sounds like you are having ownership problems rather than file permissions. Doing a chmod 0755 will do the following: Owner: Write - Read - Execute Group: Read - Execute Public: Read - Execute Which should allow users to read the directory however it doesn't necessary mean that files can be read or written to ...


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

Its difficult to understand your code, In jQuery you can get the image alt jQuery("#image_id").attr('alt'); if you need to set some alt tag you can use as below. jQuery("#image_id").attr('alt','your text'); If the image have no id or class you can select with img tag too, in that case more than one img on the same page you have to loop them like below. ...


3

I think I've got a working solution. (see https://stackoverflow.com/a/13675901/984234) <!-- links will work as expected where javascript is disabled--> <a class="intent" href="http://facebook.com/someProfile" data-scheme="fb://profile/10000">facebook</a> And my javascript works like this. note: there's a little jQuery ...


3

When a plus sign replaces a space, that is a sign that the text has been url-encoded. You just need to url-decode the text in your controller. You don't state what programming language you use, but all languages have some a function available for doing this.


3

Functionality Testing Many automated browsers such as SeleniumHQ can perform the tests. If you feel it is too complicated you can write your own script with greasemonkey / tempermonkey since you have knowledge in js and jQuery. Performance and stability testing If you expect the number of user is large, it is worth to do stress test with JMeter although ...


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

Using CDN(s) to shard your dependencies across many servers like this in essence represents a tradeoff between bandwidth and latency, assuming you only care about performance. I'm incidentally assuming the alternative is not simply hosting it locally, but concatenating it with a different local request - there's usually no good reason not to concatenate ...


3

I worked on a site that used that method, and I had problems with screen rotation on mobile devices. Since JavaScript will only detect once on page load, if the user rotates the device it won't expand to the full width the way it will with media queries. It was easier for me at the time just to switch to CSS, but perhaps a JS expert would know if there's a ...


3

Google indexes the text after the page is fully ready. I have a password creation site that uses JavaScript to write random passwords into the page on jQuery's $(document).ready. Googlebot was indexing those randomly generated passwords. I've previously asked how to prevent that indexing because random passwords aren't text that should be indexed: How ...


3

How to achieve SEO for XHTML pages which load data in DOM using a JQuery-AJAX service calls? You can load any data with Ajax call. For example, this site changes the title of all pages (it could be a meta tag too) with JavaScript and Google indexes them correctly. This site uses the "escaped URL fragments" method to be indexed. Edit: if you ...


3

JQuery isn't something you "open" it is a JavaScript library you include and reference in your website's code via <script></script> tags. An example taken from the jQuery site itself is: <!doctype html> <html> <head> <meta charset="utf-8"> <title>Demo</title> </head> <body> <script ...


2

Use PHP to make the JavaScript only load if the user is authenticated (by premium subscription?) I have created a index.html file in the js folder so that none can get access the js folder What if they guess the file name? You should be using a .htaccess for this to do a Options -Indexes to disable directory viewing; it's foolproof. But most web ...


2

I think you could use URL Rewriting and permanent images to get good Google SEO here: http://www.thenlistento.com/bands-similar-to/led-zeppelin Use URL Rewriting or Proxy to turn this into: http://www.thenlistento.com/#!/led+zeppelin Then ensure you have great meta description on the page above. When someone actually visits a page, you should turn your ...


2

The information they are providing is right because the gzipping happens on the server that gives the file. The server you are using has to be configured to allow gzipped version of javascript files. The version from Google CDN is already gzipped.


2

Single page apps have a definite downside when it comes to SEO because there is only one landing page. There is no way for you to map crawlable urls one to one between your desktop and mobile sites the way that you have it configured. You could try to make your AJAX site crawlable using Google's supported method. That would entail changing your mobile ...


2

No. "Nofollow" provides a way for webmasters to tell search engines "Don't follow links on this page" or "Don't follow this specific link." Since that link isn't an actual hyperlink but a JavaScript trigger, there's no need to use nofollow on it. Generally speaking, nofollow should be used on the following type of links: Untrusted content Paid links


2

First up, you definitely shouldn't put JSON files is a sitemap as they are meaningless to a search engine, which wants web pages. It wouldn't make sense for a user to land on your /Content/goldenglobes.json file. So if the site stays exactly as it is, then a sitemap provides zero benefit. However, if you are loading in content with JavaScript you may wish ...


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