Trace import of a certain css with Firebug - css

I am having an interesting problem debugging a css issue with Firebug. I have a page that looks "different" from the rest of the site. When I check in Firebug, one of the imported CSS files does not appear on any other page, so I removed it within Firebug and the layout issues are resolved...
So far so good, I identified the intruder file... The issue is, that I can't find the import anywhere in the workspace... Even if I check the page source code, it's not there, so I'm assuming it's getting imported the '#import' statement indirectly from some of the imported css files (nested twice or more since I can't seem to find the import anywhere I look)...
My concrete question is, is there a way to make Firebug show where a loaded resource in a page comes from?

The Referer header of the requested CSS file indicates were it was imported. You can see that header by switching to the Net panel, reloading the page and expanding the request to the "intruder file".
There's also a request for better indication of the initiator of a request, though this requires platform support.
Sebastian

Related

CSS stops working in Chrome after opening console

I'm making an app with node.js and have a few html pages that are styled with one css file. After I click on a link (to a subpage) on the home page and open it in a new tab, everything seems fine. However, after I push ctrl+F12 and open the console, the css styles somehow 'stop working', which means:
the elements are not styled, even though there is the link tag with style.css in 'Elements' tab in html
In Network tab, I can only see style.css file with status 304 listed there (all other js files are not there, even though JS scripts work)
When I return to the home page, the css styles are not visible as well (they were before new tab was open, now it's 304 status in Netwok). After refreshing, styles go back (along with status 200).
After I refresh the subpage, everything is fine again, opening console does nothing to styles (Network tab shows all the files, including style.css with status 200). After closing/ opening console again, everything is okay too.
If I dont't refresh the subage, the styles "come back" when I change window size (although not immediately, after a second). Otherwise there's just html with working js scripts.
This happens only in Chrome (version 53.0.2785.101), only after opening console for the first time. I have no clue why this might be happening.
Please help!
Ok, I managed to solve this. This issue seems to be Chrome bug, discussed for example here:
https://bugs.chromium.org/p/chromium/issues/detail?id=647151
https://bugs.chromium.org/p/chromium/issues/detail?id=648023
I am not sure whether my solution is perfect, but it now it seems to work. I just added one option into express.static in my server.js (I use Express JS):
app.use(express.static('public', {maxAge: '5d'}));
I guess the max-age property is crucial here - it's specified in Cache-Control http header (you can see this in Dev Tools console in Network tab, after clicking on given file). Found this solution mentioned in the first link. If I see further issues, I will update this answer.
I'm sorry I can't explain this problem in details.
Edit: this solution has one major flaw: when I edit my files, the browser still loads the older versions. Therefore, I turn this max-age property off when I wish to see the changes in files. If anyone has better fix, please share.
Try clearing your cache in chrome, then restart chrome and try again.
(A 304 response header is not an error necessarily. It just means that the browser should load the resource from cache. Basically the browser says "Hey, Can I use the same copy of that CSS file that you gave me last time, or has it changed?" and the Server says "It hasn't changed, go ahead and use the copy you have" AKA 304)
If that doesn't fix the issue, you may look into ETags

PhantomJS parsing CSS file's source url isn't working in script

I have a webpage with css, font, js, etc - and these files call other files.
If I use netlog.js phantomjs example, all files are requested successfully (ie response is received).
If I use my company script (1000s of lines), I don't get a font file.
When I look at the netlog.js output, the missing file is the very last received but it is the 4th of 9 in terms of requested - meaning I can see it is requested 4th but the response (page.onResourceRecieved) doesn't start until after all others have returned.
When I look at the company script, the missing file is not requested at all - hence it is missing. How can someone mis-program phantomjs to ignore this file so that it isn't requested? I assume that is the bug I'm hunting for.
In case the HTML/CSS is the culprit somehow, I'm going to include it below.
I have an html page that includes a css file via style tag (partial tag below)
<style>#import url(//fast.fonts.net/t/1.css?apiType=ad&projectid=2731384a-7cac-11e5-9c62-005056a60fc6&fontids=32RbV4zvBY&campaignid=HKyhF7DchmY);#import url(//fonts.googleapis.com/css?family=Montserrat:700&text=%2C-ABCDEFGHILMNOPRSTUVWabcdefghilmnoprstuvw);
The 1.css? request is correctly processed and the the next import of css?family is also requested. That second imported url requests another file: http://fonts.gstatic.com/l/font?kit=IQHow_FEYlDC4Gzy_m8fcqJ_SlhcvGEAn8FM2hC_Gzi8FMKbpN1MIaqg2HOsKpgsB-MyxXR1frCnhD4ZhVnHAATo_LDfaGo7fRovcW5LQvM&skey=11a939c399e8c9fe&v=v7
The netlog.js picks up the fonts.gstatic.com request - even if it doesn't come back until after everything else. The company script doesn't figure out it needs to request fonts.gstatic.com.
Netlog is very basic - it doesn't mess with timing, headers, or events. I think the company script is doing something to stop the request for fonts.gstatic.com once it is discovered by phantom via some setting or event but I don't know where to start.

Determining the Problematic CSS File in Firebug

I have this displayed in my Firebug console
"NetworkError: 404 Not Found - http://********.com/images/slider-img/ajax-loader.gif"
So it's telling me it can't find a background image. But can it pinpoint which CSS file this image has been declared as a background-image property?
I have about 4-5 CSS files being referenced in the document and the manual way of finding it out would to open each of the files and find for this image. So I was wondering if this could be avoided and have Firebug tell me which CSS file is the culprit...
Firebug currently (as of version 2.0.x) doesn't directly show you the initiator of a network request. This requires platform support, which is requested in bug 563623.
So, as a workaround you can do this:
Switch to the CSS panel.
Click into the search field at the right side of Firebug.
Ensure that the option Multiple Files is checked.
Enter ajax-loader.gif
=> The CSS panel will switch to the CSS source containing the rule containing the image value.
Notes:
There may be several properties referring to different images named ajax-loader.gif. So you should also check whether the path to the image corresponds to the one shown in the error message. (Within the search field you can hit Enter to get to the next match.)
It's not sure that the request comes from CSS. It may also come from JavaScript, e.g. through an AJAX request or by appending an <img> tag dynamically.

Chrome caching CSS but not loading images inside CSS file

We're having a weird problem at work that happens only in chrome. It looks like the css file is getting cached and the content of this file isn't getting re-downloaded.
The problem is that when using a fresh session for example "private session", the image "mainSprite.png" isn't getting displayed.
After some tests, I believe the problem is related to us doing redirects at the beginning if the user isn't authenticated. From what I understand, it might not complete the download of the sprites linked inside the css files. It will cache an invalid object as soon as the redirect starts and then on the following pages, it will fail to display a correct image since it cached something wrong.
The strange thing is that it actually loads the image completely at some point. But it looks like it's not refreshing it in memory...
I did a timeout of one second before starting redirects on first load and images correctly display. This is a quick fix and I can't expect every computer to load in 1 second every images contained in the css.
edit
As far as I can say, it really looks like a race condition. I changed the order of loading. We use require.js. Instead of loading js after css, I start js loading before. And images are getting loaded correctly now on my local server.
if someone is interested to look into it:
http://api.checklist.com
edit 2
When images aren't visible, opening new tabs will have the same problem. Closing the browser and reopening it will work on first load and images isn't being downloaded but loaded from Cache which means that before closing the browser, the image was indeed downloaded.
It looks like the problem coming from your redirects unfortunately i couldn't see your example ( link won't open ). Google chrome has indeed issues with caching it's annoying during development time ( clear up the cache, load new image, do the same for new image..), if you need to clear your cache try the folowing:
try to go to
chrome://chrome/settings/clearBrowserData
in your chrome browser and check the options:
Empty the Cache( i have also Clear download history and Delete cookies and other site and plug-in data )
click on 'Clear Browsing Data' button it should
All what you need to do is to trace your cash list via chrome, and from what I see is that you got this error which make it not cached:
Uncaught TypeError: Object [object Object] has no method 'placeholder'
So if you want to trace, you can use the manifest offline mode or you trace via your code.
Just following and test your page, I did catch where the error is:
file: scripts2.js Line 20 --> $('input[placeholder]').placeholder();
which you need to check the name of the place holder and change it here in this tag.
Thank you
I assume your server/backend app has routes set up. Like this Play! framework example:
# Ignore favicon requests
GET /favicon.ico 404
# Map static resources from the /app/public folder to the /public path
GET /public/ staticDir:public
# Catch all
* /{controller} {controller}.index
According your summary I suggest to set up a static folder route (where the images are) in config file or htaccess as you want, then check image url in browser url bar (with empty session). That should work!
First I would suggest that you first try to find ways to narrow the redirects. If it possible I would suggest that it would be much more advisable to try to create your content dynamically based on your users authentication using languages like PHP or ASP (just to name two).
The classic way of disabling the caching on a webpage is to set two <meta> tags inside of your <head> </head> tags. However, you should note that these are technically not "correct" as they are not part of any of the "offical" standards documentation. This also means that I would again lean towards my first suggestion of finding a better delivery system which in turn should prevent the problem.
So for "testing" purposes the tags would be:
<HEAD>
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="EXPIRES" CONTENT="0">
</HEAD>
Maybe I don't understand your question or dilemma (maybe because of lack of explanation or because I can't see your page at that link since I run Chrome), but there's an example I ran across here that works in Chrome by just using Javascript/jQuery to load, instead of CSS:
http://jsfiddle.net/2Cgyg/6/
Use image at URL: http://www.w3schools.com/cssref/img_tree.gif
And although the accepted answer didn't work for me in Chrome, this is the question I got the jsFiddle above, from:
Load Image from javascript
All the caching, etc. is unnecessary, and even something you wouldn't want to do if your images are ever updated to something else - they won't appear without forcing a refresh which you can only do through altering the file name like this to avoid users not seeing your updated image:
myPic.jpg?MMDDYYYY
And you could set the date according to the date you are modifying it.
clean your browser history like cache,cookies
clean the temporary internet file
if problem not solved then reinstall browser your problem is solved definitely

Sys undefined for HTTPS url in IE8

I just discovered a rather peculiar issue in IE8 for a HTTPS link. Every time the page tries to access the HTTPS link, it produces an error. This happens only in IE8 and nothing else. Any idea what's going on? I found some items that said that means the files were not loaded, hence the issue and tried some fixes recommended, but they haven't worked so far. This is a .NET site by the way.
https://www.beckshoes.com/cart/cart.aspx
Message: 'Sys' is undefined
Line: 70
Char: 1
Code: 0
URI: https://www.beckshoes.com/cart/cart.aspx
Message: 'Sys' is undefined
Line: 319
Char: 1
Code: 0
URI: https://www.beckshoes.com/cart/cart.aspx
Looks to be a JavaScript error. Firefox handles it fine, but Sys is undefined in IE8 so I'm guessing that the part where it normally gets defined is missing in IE?
Use View > Source.
Is the <script src="..."> coming from the https server as well, or is it coming from http? IE8 may not be loading the script because it isn't coming from the same secure source the rest of the page is coming from. Take the <script src="..."> (if it does not include the protocol and server, use the same one the page is coming from) and paste it into the address bar of a new tab, does the script load/download?
Is the <script src="..."> tag that loads the appropriate library even listed in the source? Maybe it isn't being added because ASP.NET doesn't recognize the User Agent and doesn't think it is capable or something.
Sys is part of the Microsoft script library, and is loaded through the WebResource.axd file.
Your page seems to be mostly working in IE 8 for me - have you fixed it?
I see that you're loading the WebResource at the foot of the page - if the calls to initialise are happening before the script is loaded, then that will be what is causing it - have you deliberately moved this to the footer? The scriptmanager has a property to do this correctly: LoadScriptsBeforeUI. Setting this to false will move those scripts that can be moved down to the bottom of the page.
I notice you've also pushed the viewstate down there, so you're clearly doing som post processing of the html.
The only other thing I can think of is that looking at your page, you've got an IFrame holding the brand rotator, that is requesting it's content from http://www.beckshoes.com/brands.aspx
You really want that under https as well - that's probably not helping.

Resources