Questions tagged [javascript]

JavaScript is a dialect of the standardized ECMAScript programming language, primarily used for scripting web-pages. Use this tag for questions regarding ECMAScript and its dialects/ implementations: JavaScript, JScript, etc., excluding ActionScript.

Filter by
Sorted by
Tagged with
92 votes
2 answers
713k views

How do I open the JavaScript console in different browsers?

Web browsers provide a JavaScript console as part of their developer tools. This console is useful for the following reasons: Errors and warnings that occur on a web page are logged into the console. ...
55 votes
17 answers
3k views

HTML validation: is it worth it?

What are the advantages and disadvantages (if any) of making sure that all pages validate compared to having non-valid HTML that however works on all major browsers? Also, is having valid HTML after ...
user avatar
40 votes
4 answers
106k views

How do I set expiration headers for CSS, JS, and Images?

I have recently analysed my website with pagespeed addon on firebug. It suggested me to set expiration on CSS, JS and image files. I am wondering how do i do this?
user avatar
  • 1,658
34 votes
5 answers
75k views

Chrome refused to execute this JavaScript file

In the head of my HTML page, I have: <script src="https://raw.github.com/cloudhead/less.js/master/dist/less-1.3.3.js"></script> When I load the page in my browser (Google Chrome v 27.0....
user avatar
  • 791
34 votes
2 answers
7k views

Someone else is using our Google Analytics Tracking code number. What do we do?

After looking over our Analytics today, I realized that another website is also using our same tracking code #, which is cause quite a few incorrect hits to our Analytics. Are there any ways to ...
user avatar
33 votes
1 answer
29k views

How does CloudFlare's Rocket Loader actually work (and how can a developer ensure compatibility)?

CloudFlare has quite a ground-breaking technology called Rocket Loader (both on free and paid accounts). But how does it actually work? They have a couple of pages that describe the technology, but ...
user avatar
31 votes
8 answers
30k views

How do you exclude yourself from Google Analytics on your website using cookies?

I'm trying to set up an exclusion filter with a browser cookie, so that my own visits to my don't show up in my Google Analytics. I tried 3 different methods and none of them have worked so far. I ...
user avatar
30 votes
5 answers
8k views

Why insert static files (CSS, images, JavaScript, ECC) in a subdomain?

Why so many big and little sites inserts static files (CSS, images, JavaScript, ECC) in a subdomain like media.example.com or s2.static.example.com? What are the advantages? Why not just a directory ...
user avatar
  • 401
28 votes
5 answers
11k views

Does "putting Javascript at the bottom" defeat the purpose of document.ready?

I know that it is recommended to put Javascript at the bottom of the page, but if I'm using jQuery doesn't this defeat its purpose to run as the DOM is loading? If I have a dropdown menu, for example,...
user avatar
27 votes
3 answers
11k views

Lazy loading images and effects on SEO

We are using the following technique to lazy load images in our site: For all images we put in the src attribute a url for a default img (i.e. a loader) and put the actual image url in the data-src ...
user avatar
  • 447
26 votes
5 answers
6k views

Does the Google spider render JavaScript?

Does the Google spider knows how to render JavaScript, or only HTML?
user avatar
24 votes
5 answers
2k views

How can I reduce the costs of loading large JS libraries?

If I am using a large Javascript library for my page, how can I make sure that this does not impair the user's use of the site?
user avatar
  • 1,290
24 votes
6 answers
5k views

Can we ignore visitors without JavaScript enabled?

If you have developed a JavaScript based website, is it worth doing the extra work to make it accessible for visitors who don't have JavaScript enabled? What percentage of visitors are in this ...
user avatar
20 votes
8 answers
8k views

Is inline JavaScript good or bad?

I've currently switched from WordPress to Yii framework and an external developer is rebuilding my site. One thing I notice is that each time he invokes AJAX / jQuery the Yii way, it embeds inserts ...
user avatar
  • 489
20 votes
5 answers
568 views

What documentation exists for HTML, CSS, and JavaScript?

PHP users have the PHP.net docs Ruby users have Ruby-Doc.org Python users have docs.python.org jQuery users have docs.jquery.com All are considered go-to references when working within those ...
user avatar
  • 20.3k
15 votes
5 answers
5k views

Should I worry about people disabling Javascript?

Often when picking new tools and frameworks I see the warning "Will not work if the user has disabled Javascript". I then look at my Javascript powered slideshow, Javascript powered menu, and ...
user avatar
  • 574
15 votes
5 answers
6k views

What's the best way to load Javascript into a page to optimize performance?

Is there a way to load my JavaScript into a page that will make it load faster?
user avatar
  • 2,158
15 votes
2 answers
7k views

Is this a good approach to image Lazy Loading for SEO?

For images loaded via AJAX, or that I don't want indexed, use the data-* attribute approach: <img data-src="path/to/image.jpg" class="js-lazy-load" /> The javascript maps the data-src ...
user avatar
  • 153
14 votes
8 answers
4k views

What should I use to automatically combine css/js files?

I'm aware of sprockets for combining javascript files, but haven't tried it. What are some other options and how do they stack up?
14 votes
1 answer
698 views

When and when not to use a CDN

I'm working on a web-application that loads a couple of small gif images onto the screen. I'm using a relative path, which means they are loaded from the same web server that serves the php page. The ...
user avatar
13 votes
4 answers
4k views

Loading main javascript on every page? Or breaking it up to relevant pages?

I have a 700kb decompressed JS file which is loaded on every page. Before I had 12 javascript files on each page but to reduce http requests I compressed them all into 1 file. This file is ~130kb ...
user avatar
  • 315
13 votes
4 answers
5k views

Pagespeed Insights reports that Google Analytics is blocking main thread in page load

I'm chasing page speed, partly as proof that getting 90%+ is consistently achievable. My main issue now is Google Analytics. In the below example, it's loaded via Google Tag Manager, so there's just ...
user avatar
12 votes
5 answers
344 views

Should JavaScript referenced in the head section be served from the same hostname as the main document?

I was under the impression that for the best performance, Javascript should be treated as static content and served from a cookieless domain along with CSS files, images, etc. But Google says here: ...
user avatar
12 votes
5 answers
18k views

Why would you use document.location.protocol instead of plain // prefixed urls?

For instance Google Analytics uses document.location.protocol in the boilerplate for tracking: <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXX-X']...
user avatar
  • 3,633
11 votes
4 answers
5k views

Should I combine js/css files into a single file?

Both YSlow and Google's Page Speed add-ons recommend combining script (and style) files into a single file each to reduce the number of HTTP requests, and I can certainly see the point of this when ...
user avatar
  • 512
11 votes
8 answers
10k views

Why not AJAX'ify entire websites?

Is there any solid reasoning as to why sites shouldn't be developed with ajax functionality that loads major parts of each part (assuming there are elements like the header, navigation etc that remain ...
user avatar
  • 2,824
11 votes
1 answer
220 views

What is the benefit of using Google Analytics' asynchronous tracking code compared to the non-asynchronous code?

What, specifically, does the asynchronous code accomplish or allow that the older code does not?
user avatar
11 votes
2 answers
664 views

Automated Website Testing/Sanity/Quality

I am thinking about building a tool that starts from the root of a webpage and traverses the entire website gathering a list of resources such as CSS/HTML/Javascript files and then runs CSS/Javascript ...
user avatar
11 votes
2 answers
584 views

Google indexing pages with #! although we don't have any

Our company has developed a Single Page Application using AngularJS and its routing. Google indexed our site decently with JavaScript but it did not index some pages very well so we have developed an ...
user avatar
10 votes
5 answers
254 views

What new cross-browser features can we use if we drop support for IE6?

My company is dropping support of IE6 and I just realize that we can use a set of great features. Is there a list of CSS, Javascript features which we can use with IE6 RIP?
user avatar
9 votes
4 answers
10k views

Protect Javascript code from being stolen

I developed a web app with jQuery, HTML, and CSS markup which would be a premium web app. So I have to ensure the security of the code from being stolen. But, as all these are client side, there is no ...
user avatar
9 votes
3 answers
6k views

Directory structure for a website (js/css/img folders)

For years I've been using the following directory structure for my websites: <root> ->js ->jquery.js ->tooltip.js ->someplugin.js ->css ->styles.css -&...
user avatar
9 votes
4 answers
23k views

What is the optimal folder structure for a web directory?

I've been doing web development for years, and I've always done a web structure similar to this: public_html/login.php public_html/css/login.css public_html/js/login.js public_html/img/logo.png I've ...
user avatar
9 votes
1 answer
2k views

Does adding external images or javascript to a website affect its SEO?

When adding images to your site, is it bad to use an image located on another site: <img src='http://www.some_other_site.com/image.jpg'> The same goes for javascript, is it bad to link to ...
user avatar
9 votes
3 answers
23k views

Upload image file: is compression on client side already possible?

When offering photo file uploading, usually the user will have badly compressed and huge (10+ megapixels) JPEG files from their cameras or phones. On the server side, these files will get re-...
user avatar
  • 141
9 votes
1 answer
18k views

Is it necessary to specify content-type in http response header?

Except for the html document, currently all the files (css, javascript and images) served from my web server do not specify the content-type in the http response header. I happen to notice this as I ...
user avatar
8 votes
9 answers
801 views

How do I compress my JavaScript and/or CSS?

I know that there are ways to dynamically load it into the page, but if I want to compress my code so it loads even faster, how do I do it?
user avatar
  • 2,158
8 votes
2 answers
2k views

Anyone still using JavaScript disabled? [duplicate]

Is there anyone left that's not using JavaScript? When designing websites, is it worth to care about that fraction of visitors? At least in Firefox you can't even disable it anymore.
user avatar
8 votes
7 answers
3k views

Can anyone list some real examples of 'HTML5' being used in the wild?

I am using HTML5 in the same way everyone seems to be using it these days, meaning: HTML5 tags, Canvas / 3D / javascript and CSS3. I am struggling to find examples of sites that are using these ...
8 votes
2 answers
19k views

Tracking logged in vs. non-logged in users on the same URL in Google Analytics

I am building a social media site that is similar is structure to twitter and facebook.com where unauthenticated users who go to https://example.com will see a login + sign-up page, and authenticated ...
user avatar
  • 273
8 votes
1 answer
2k views

Structured Data Tool doesn't see JavaScript rendered content

Some structured data (namely price) of my page is rendered by JavaScript. According to fetching results in Webmaster tools Googlebot sees and renders it perfectly. However the structured data tool ...
user avatar
8 votes
2 answers
582 views

Is Facebook mining passwords from my website?

I just took a look in my bug tracking software and noticed a lot of client-side errors that look like this: SecurityError SecurityError (DOM Exception 18): Blocked a frame with origin "https://...
user avatar
8 votes
1 answer
1k views

Googlebot encountering JavaScript errors due to rendering outdated HTML files with newer JS files

We recently encountered an issue where we added a JavaScript variable (e.g. var GLOBAL_VAR = true;) to an HTML page (e.g. /Search/Index) and updated the separate JS file (e.g. /Scripts/search/index.js)...
user avatar
8 votes
1 answer
472 views

What do I need to do to make my site compatible with Safari's iCloud Keychain so that it saves passwords?

I've noticed that a vendor's web application triggers Safari's "suggested password" feature at "create password" forms, but does not actually save this password when the form is submitted. That is, ...
user avatar
  • 143
7 votes
9 answers
1k views

prototype.js or jQuery for new projects?

Should I use prototype.js or jQuery for a new project? Rails comes with prototype.js but jQuery seems the library of choice for the rest of the world. Is prototype.js still under active development? ...
user avatar
  • 289
7 votes
6 answers
472 views

Font resizing widgets: worth it?

I see some text-heavy sites implement the little JavaScript widgets that allow you to choose smaller or larger text sizes on sites. (e.g.: as described on the Guardian's website) Are these little ...
user avatar
  • 8,468
7 votes
3 answers
2k views

How do I prevent Google from indexing text that is generated by JavaScript?

Google is executing the JavaScript on my password creator website and indexing the random passwords that get generated by the JavaScript. The random text that is generated could look spammy to Google ...
user avatar
7 votes
4 answers
421 views

Who Is Against CSS and JS?

I know there is a group which promotes very basic HTML. They advocate against CSS and JavaScript. Does anyone know the name of this group? Just to be clear this was a website, or a foundation, or a ...
user avatar
7 votes
3 answers
5k views

Would redirecting to a new home page affect SEO?

I'm currently working on a new landing page for this site. I want the landing page to replace the existing front page of the site. However I don't want to lose the Page Rank of the current front page -...
user avatar
  • 183
7 votes
2 answers
5k views

What are the differences between Firefox's Javascript engine and Chrome's V8?

I've noticed that Chrome and Firefox take different amounts of time to render certain things. In general, Chrome has been faster. What should I know about both of them (and IE8/9, too, I guess) when ...
user avatar
  • 2,158

1
2 3 4 5
16