Detect when a stylesheet is loaded twice - javascript

I'm trying to debug my site in IE11 but it crashes when opening developer tools by F12.
Apparently this could be because of a CSS loading twice
https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/7115490/
How can I find which CSS causes the issue? I tried to look at the CSS resources loaded in Chrome in the Network tab, but there's no same css called twice. I am not sure it would even display it twice there.
Is there a tool or technique I can use?

Follow these steps to check if (IE or) your web page is loading duplicate CSS files:
Disable script debugging to prevent IE from crashing.
IE > Tools > Internet options > Advanced > Browsing > [X] Disable script debugging (Internet Explorer)
Press F12 to open the Developer Tools window.
Click on the Network tab.
Filter traffic by CSS files.
Content type > [X] Style sheets
Browse to or reload your web page and check to see if there are multiple CSS files loaded twice.

Related

Can I live-debug any website on browser?

I know there are tools which allow us to debug our own website? How can I debug(or analyze) any website, for eg:- Amazon, Google?
Basically, I want to add print functions(in JS) and add breakpoints (in JS) in the execution of a website. How is that achievable, if at all.
We can live-debug (and play-around) CSS and HTML on the browser itself, but how to debug JS on the browser?
On Google Chrome for exemple, open the DevTools window by pressing F12 and right-click on the HTML element. Then go on Break on -> and choose subtree modifications. Your app will stop at page loading and you will be able to do step by step analysis.

Chrome automatically blocks javascript when open Developer (F12)

I have a problem with Chrome running on my PC.
Websites are running fine on Chrome, but whenever I open developer tools (F12), Chrome blocks that site's javascript. Keep the developer tools opened, and refresh the page (F5), Chrome loads the site with without any scripts.
This happens to all websites.
Incognito mode doesn't encounter the issue.
I checked settings in Chrome and it allows JS.
I tried to disable extensions, doesn't work.
I re-installed Chrome, doesn't work.
I tried to run using a different Chrome user account. Work fine.
But I am a developer so I don't want to use incognito mode all the time or use different account.
Please help,
Hoang
Edit:
* Add screenshot
Select settings from "Inspect element window" and untick the "disable Javascript" check box

Get rid of [dynamic] JavaScript views in Visual Studio

Since I installed Visual Studio 2010 from scratch about 2 months ago, it behaves slightly different when debugging JavaScript code being run in IE.
When I set a breakpoint, it opens a duplicate of the view with the term "[dynamic]" in the header and marks the breakpoint in there.
When a JavaScript error happens during execution, it does the same before it marks the line of code that threw the error.
This "dynamic" view is editable but edits have no effect - they are not saved to the file.
I find this behavior pretty uncomfortable. Everytime I notice an error in the code during debugging, I happen to fix it in the dynamic view. I hit save. VS does not complain. Next I refresh the page in IE, and - bang - the changes are lost, it loads the untouched old version again.
I haven't been able to find out how I can turn these views off. Before I re-installed Visual Studio it did not do that. It would only create "dynamic" views for script found in inline script tags in HTML files.
Try this
IE > Internet Options > Settings (under browsing history) > Check for new version of stored pages : Every time I visit the webpage.
This works for me in IE10.
Other option is to open Developer tools and select cache option Always Refresh from Server as show in the image below
Try hitting CTRL+F5 on the web page. That did the trick for me.
The problem was that I had opened other IE windows from a previous debugging session, so the dynamic javascript files were still cached.
Having developer tools open - F12 - should also cause the cache files for the page to be cleared on each refresh.
Changing the encoding of the JS file in question, from a Windows codepage to UTF-8, fixes this for me.
Narrowing it down, it appears that OEM Extended ASCII characters in the file (e.g. ALT-254 which I use for a bullet) trigger the problem with the Windows codepage files.
(Visual Studio 2013 Update 5, IE11)
For Google Chrome:
Open developer tools(F12)
Open Network Conditions Tool
Select Disable Cache
I had the same problem of not being able to hit a break point in new code. And breakpoints on old code in the same page will bring up the [dynamic] version. The edited page is not reloaded. This just started for me a week ago in both VS2012 and VS2013. Using refresh page and/or Ctl-F5 did not work for me. BUT, reading this thread pointed me to using F12 to open Developer tools. Leaving that window open, while hitting refresh does the trick. Thanks guys.
1) Run the page Without Debugging (Debug-->Start Without Debugging)
2) While the web page is open in Internet Explorer, press Ctrl-F5 so
that the IE cache is cleared. Ensure IE has the focus.
3) Close IE and re-run the page with Debugging (Debug-->Start
Debugging).
This fixed the issue for me.

scripts tab or scripts panel are not showing in Google Chrome

When I open Google Chrome's developer tools, I do not get the scripts tab. I have done this on two computers, one running Windows 7 and the other Windows Server 2008 R2. Can you please tell me what I need to do to get the Scripts tab back. Many thanks!
Screenshot of what you are seeing? Scripts are under 'Sources' now
There is no scripts tab in the Chrome debugger any more. You can view the javascript under the Resources tab (though I don't find it all that useful in the Resources tab).
You can view and set breakpoints in your scripts under the Sources tab. Go to the Sources tab now, click on the right facing arrow at upper left (right below Elements) and then find the script you are looking for. Click on it there and it will create a tab with just that script in it. You can then set a breakpoint.

Why isn't Google Chrome reloading my scripts?

So, I have a script called "engine", and after much headbashing and (futile) debugging, I've found out that GC simply isn't reloading it!
This is how I include it in the webpage (inside the <head> element):
<script type="text/javascript" src="engine.js"></script>
When a put 10 console.log("asdf");'s at the start of the script, it's like they aren't there. When I went to the "resources" tab in the GC console, I saw that no changes are being applied whatsoever to that script! Hlep? Would putting a + "?" + new Date() at the end help?
The universal solution that works in Chrome, Firefox and IE is cleaning the cache via Ctrl+Shift+Del (on Mac ⌘+Shift+⌫).
Chrome solution #1
Open Developer Tools (F12 or ⌘+⌥+i, or right-click → Inspect).
Select the Network tab and tick the Disable cache checkbox.
Reload the page.
❗️Note: The cache will be disabled only when the devtools window is open.
Chrome solution #2
This only makes sense if #1 is not used.
Open Developer Tools.
Click the Settings cogwheel icon in the bottom right corner.
In the dialog that appears, select under the Network subsection the Disable cache checkbox: from now on the cache will be skipped when the devtools window is open. When the devtools windows is closed caching will work as usual.
Chrome solution #3: empty cache + hard reload
Open Developer Tools (otherwise the menu in the next step won't show).
Click and hold down the Refresh button, and then select from the dropdown Empty Cache and Hard Reload.
Modifying javascript code
A browser-agnostic solution which could be used for debugging is to append in your server-side code a randomly-generated version string as a query parameter, i.e. call your script as:
<script type="text/javascript" src="myscript.js?ver=12345"></script>
This trick will force the browser to reload the script when the value of the ver parameter changes. If you make ajax requests then you can append "?ver=" + new Date().getTime() to your URL.
NOTE: Don't forget to remove the parameter when you are finished debugging because in production you most likely do want the scripts to be cached. It is a common practice though to generate a new timestamp on each new build — this can be used in production, and will ensure that after a new deployment the clients will always get the updated scripts.
Unlike all the above solutions this one will work even when you have some sort of caching (e.g. redis, memcached, varnish) or CDN (e.g. akamai, cloudflare, cloudfront, etc) between the client and the server.
It is possible that the script is cached so the old version is loading from cache. If you want to make sure you get a new version, you can force a browser reload, clear your browser cache or change the name of the script or put a different query parameter on the end of the filename.
This bugged me as well; CTRL+F5 or SHIFT+F5 never worked...
The only things that works is opening your dev tools (hit F12), and right-click the reload icon next to the address bar and then selecting either "Hard Reload" or "Empty Cache and Hard Reload"
As I said in the comment I guess it's a cache problem, a CTRL+F5 should be enough, in case it is not go for CTRL+SHIFT+CANC and clear browsing data. However sometimes it's the server that has some kind of cache, I say that because with IBM WebSphere I often get cache problems that I can't resolve with a simple F5 on my browser. I just have to wait for my web server to "refresh" itself.
In the latest chrome stable 21st Oct 2016.
Open Developer Tools (F12 or right-click > Inspect or vertical ellipsis icon in address bar right corner > More Tools > Developer Tools).
Click the vertical ellipsis icon in the top right corner of Developer Tools navigation bar > settings.
In the Preferences section find the Network > Disable cache.

Categories

Resources