6

I am having a strange problem in Google Chrome. I am including a js file via script src tag. I place alert('test') in the file and when I load the page in Chrome, It alerts twice. In every other browser it alerts once. Is there any known cause for this?

Here is the code that loads the JS:

<script type="text/javascript" src="/js/main.js"></script>

It appears this happens in Safari as well. Does not occur in IE and firefox.

11
  • 3
    please post the code that loads the javascript Commented Jun 14, 2011 at 0:20
  • 1
    Add debugger; to the beginning of your javascript code and then step-through setting break points in the Dev Tool. Commented Jun 14, 2011 at 0:23
  • Ok I did that and it seems to go over the same code twice as I keep clicking "step into next function call". It read from line 0 to the last line then goes back to 0 after the last line. After the second time going down the script it stops. Commented Jun 14, 2011 at 0:26
  • 1
    can you post the code from main.js? Commented Jun 14, 2011 at 0:33
  • 1
    If you found the solution yourself, please post it as an answer and accept it in a few days. That way those that have the same problem in the future will know what to do. Commented Jun 24, 2014 at 14:43

3 Answers 3

12

I had this recently and eventually found out it was a chrome extension, specifically the cache killer extension

Sign up to request clarification or add additional context in comments.

1 Comment

This was it for me too! Thank you! Looks like the page load-time is the same - it just reports the files are loading twice.
0

This might be helpful

Webkit browsers (Chrome, Safari) are loading pages redirected from .htaccess twice!

1 Comment

I found the problem - I had a hidden iframe in the page with its source set to "#". This causes the page to load again in the iframe in Chrome/Safari.
0

I've noticed this same problem in Chrome. I have some code that runs when the page loads and I have an alert inside that code. In every browser other than Chrome this code is run once, thus the alert displays once. In chrome the alert shows twice. I am not doing anything special, just running code when the onload event is triggered within <body onload="somefunction()">. I am not using links, iframes, or the Cache Killer extension. I tested it in Safari and the code is only being called once. This seems to be a Chrome specific problem.

I did some research and it appears this is a bug with Chrome. I found this link https://code.google.com/p/chromium/issues/detail?id=64810

Depending on your specific situation, this page may give you a work around for the problem.

The problem does not seem to be fixed as of yet.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.