Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9081963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:26:36+00:00 2026-06-16T20:26:36+00:00

I’m using Google hosted jQuery in my webapp (//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js) As part of bug diagnostics

  • 0

I’m using Google hosted jQuery in my webapp (//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js) As part of bug diagnostics I have a window.onerror handler which catches any errors I’m not catching locally and lets the server know about them.

So far so good, but… sometimes i get errors like these:

“Script error.”,”Error loading script”,”Unexpected token <“

My assumption is that the Google CDN is blocked in these cases (for whatever reason). I do have a local fallback for jQuery, that I’m fairly sure is working well, but I would like to find out what’s being returned so that I can test my assumptions and maybe get some of these users on a white list for Google CDN (if it’s company firewall blocking it).

But so far I haven’t been able to figure out how to retrieve the returned content. Can’t retrieve innerText of a SCRIPT tag if it’s a file, can’t do an ajax request because of cross-domain policy, etc.

Does anyone have any ideas about how this would be possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T20:26:37+00:00Added an answer on June 16, 2026 at 8:26 pm

    It simply isn’t possible to get the content of any file referenced by a <script> tag. This is with good reason: doing so would allow you to circumvent XHR’s Same Origin Policy.

    Consider:

    <script src="https://www.example.com/private/api/getAuthToken" id="s"></script>
    

    If you could access the text of the respnse, you’d be able to do this:

    var stolenAuthToken = $('#s').text();
    

    That’s obviously bad. Therefore, you’re never allowed to read the content of something brought in by <script> tags.

    Your particular situation is complicated by a relatively recently introduced change where errors in cross-origin scripts do not report any useful information to your page’s onerror handler. (Essentially, this was done to patch an information disclosure security hole that allows a malicious site to infer whether you’re logged in to some well-known sites, among other things.)

    This means that you get no useful information about errors from CDN-hosted script, so another change was made to allow the use of CORS for a CDN (or other non-same-origin) server to opt in to allowing full error details to pass to an onerror handler.

    We (Facebook) need a mechanism for disabling the window.onerror muting behavior implemented in #363897. Our static script resources are served on a CDN under a different domain from the main site. Because these domains differ we’re falling afoul of the x-domain logic that prevents us from gathering useful information about browser errors.

    This "feature" has been widely enough adopted in in the wild (in Firefox and Webkit browsers) that the majority of uncaught exceptions we see in production now have no actionable information in them.

    The crossorigin attribute (originally intended for <img>) allows you to specify that a resource should be loaded with CORS rules. It has been implemented by Mozilla, WebKit, and Chrome.

    <script src="http://example.com/xdomainrequest" crossorigin="anonymous"></script>
    

    Unfortunately for you, in my testing, I found that the Google CDN does not send CORS headers.

    GET http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js HTTP/1.1
    Host: ajax.googleapis.com
    User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0
    Accept: */*
    Accept-Language: en-US,en;q=0.5
    Accept-Encoding: gzip, deflate
    Connection: keep-alive
    Referer: http://fiddle.jshell.net/josh3736/jm2JU/show/
    Origin: http://fiddle.jshell.net
    Pragma: no-cache
    Cache-Control: no-cache
    
    HTTP/1.1 200 OK
    Vary: Accept-Encoding
    Content-Type: text/javascript; charset=UTF-8
    Last-Modified: Tue, 13 Nov 2012 19:53:02 GMT
    Date: Wed, 02 Jan 2013 22:54:25 GMT
    Expires: Thu, 02 Jan 2014 22:54:25 GMT
    X-Content-Type-Options: nosniff
    Server: sffe
    Content-Length: 93637
    X-XSS-Protection: 1; mode=block
    Cache-Control: public, max-age=31536000
    Age: 169036
    
    ...
    

    Note the presence of the Origin header in the request (indicating a CORS request), and the absence of an Access-Control-Allow-Origin header in the response. Thus, even if you put the crossorigin attribute, the CORS check will fail, and your scripts will receive scrubbed error details.

    There is a three-year-old issue to enable CORS on the Google CDN server. I wouldn’t hold my breath.


    tldr: If you want meaningful error messages, you must host all JavaScript yourself, on the same origin.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.