DevTools Coverage Activity - google-chrome

I want to remove unused code from my files and I am using the Coverage tab from DevTools. My problem is that Coverage shows only used code from the static page, if I have styles(hovers for example) or scripts that are not active on page load, Coverage shows them as unused code. Is there any way to force load all inactive scripts and styles so Coverage will show them as used code and not unused?

Related

How to show the whole source code of load more page after clicking on load more botton?

I have a problem with this page!
when entering it, you can right-click and view the source code via, say, chrome and see the articles with their links..etc. However, when pressing on "المزيد" and viewing the source code again, the source code of the new articles does not appear. Only the source code of the previous articles does.
What would you recommend to solve this problem?
I have pressed on view page source code on google chrome, but nothing appeared regarding the new articles.
The View source option only shows the source code of a page as it was delivered from the server. It does not take modifications performed using JavaScript into account.
The button mentioned in your question loads more content and inserts it into the page programmatically using JavaScript.
You need to use the Elements tab of Chrome Developer Tools to see programmatically inserted HTML code. Right-click anywhere on the page and choose "Inspect", or press Ctrl+Shift+I or F12 on Windows. (Shortcuts on other platforms may vary.)

Browser Inspector how to know if image or other resources belongs to which css or js file that was failed to load?

I can see some images in my webpage that are not loading the reason is the wrong path inside the css or js file but how to know which js or css file is trying to load that resource. I tried too much in browser's inspector to find some way but I cannot figure out so I have to search each js and css file for the resource name. Is there any way to know the exact js or css file that is trying to load the failed resource.
Thanks
The Firefox and the Chrome DevTools provide a way to see what initiated the request of a resource within their Network panels.
Chrome DevTools
The Network panel within Chrome's DevTools provides information about the origin of a request within an Initiator column. All entries except the ones saying 'Other' link to the line within the JavaScript, CSS, or document, which caused the request.
For JavaScript calls it shows the stack trace that led to the request on hover.
It even allows you to highlight the initiators and dependencies by holding down Shift and hovering entries within the list.
Firefox DevTools
The Firefox DevTools Network Monitor has a Cause column indicating if a request came from JavaScript, the document, CSS, or some other source.
For JavaScript calls it provides the stack trace within a Stack Trace side bar when selecting the entry.
Unfortunately, for causes other than JavaScript it doesn't provide much useful information or links to the source files yet (as of Firefox 55). Therefore I've filed several enhancement requests to improve this feature.

Multiple GET requests for the same CSS file in Firefox Inspector

There is only one place in my page that links to this css file:
<link rel="stylesheet" href="http://domain.com/css/23beac5f7ba9d3e94ba463892e86b2ff.0.1.css">
However, when viewing the network tab in Firefox's inspector, it is counting two requests for this file (which exists), and also counting the size of the css file twice in the total size of all files requested.
The request at the end in this screenshot loads last, and takes a while longer than the rest of the requests to appear. The only thing I notice different about the two is that the last one under "Cause" has a "JS" symbol next to where it says "stylesheet". I do not know what that means or why it's there.
Any suggestions as to what might be causing my css file to load twice like this?
Might be this bug : https://bugzilla.mozilla.org/show_bug.cgi?id=1306892
If you opened the Inspector or Style Editor before opening the Network Monitor, it triggers additional requests to CSS files that unfortunately show up in your requests list.
To verify this:
select Net Monitor in FF Devtools
close devtools
reload your site
open devtools
Devtools should open on the Net Monitor tab directly and you should not see any duplicate request.
The second request was caused by a javascript file. According to Mozilla's Developer Tools docs:
When a request was triggered by JavaScript, a small JS icon is shown to the left of the entry in the Cause column. Hovering over this displays a popup containing the stack trace for the request, to provide more clues as to why a request happened.
Try hovering over the JS icon to get more info on what javascript file made the second call.
Update: You can also try viewing the page in Chrome. The network tab in Chrome's Developer Tools column has an "Initiator" column that shows which file initiated the call.

devtools will not show the changes on less files modification

I am trying to use devTools to modify local less file and sourceMaps to directly see the result in the page.
I've used bootstrap and the provided less files and the map file as well. I didn't modify anything to be sure that my first testing file wasn't compromising anything.
I am using the last build of the chrome browser. I have set the workspace in devTools as to made possible the edition of the source files, as well as I've checked the option allowing devTools to use sourcemap and auto-reload changing css.
When I load my page and inspect an element, the less file link is well showned in the css inspector.
However when i edit the less file directly in the devTools and save, nothing happened. the content's appearance should change.
Do you have some suggestions ? something i may do wrong ?
I finally understood that devtools is not processing less files but rather refreshes the page whenever the less files are being modified externally.
Technically the less files are being watched by a program (e.g. grunt-contrib-watch module) and when they are modified the compilation is generating the stylesheet again which is spied by devtools and consequently refreshes the page.
The modification of the less files themselves in devtools is made possible by adding the less files in the devtools workspace.
More informations following the links :
grunt-contrib-watch : https://github.com/gruntjs/grunt-contrib-watch
devtools : https://developer.chrome.com/devtools
less : http://en.wikipedia.org/wiki/Less_(stylesheet_language)

How to save CSS changes of Styles panel of Chrome Developer Tools?

How to save CSS changes of Styles panel of Google Chrome Developer Tools?
At tool's website it's mentioned that we can see all change in resource panel
But I'm working locally on a CSS file but changes are not showing in Resource panel for me
By the way Do you know any add-ons , tools to save css changes of Chrome Developer tools?
I know for Firebug there are many https://stackoverflow.com/search?q=firebug+CSS+changes+save
You can save your CSS changes from Chrome Dev Tools itself. Chrome now allows you to add local folders to your Workspace. After allowing Chrome access to the folder and adding the folder to the local workspace, you can map a web resource to a local resource.
Navigate to the Sources panel of the Developer Tools, Right-click in the left panel (where the files are listed) and select Add Folder to Workspace. You can get to a stylesheet in the Sources panel quickly by clicking the stylesheet at the top-right of each CSS rule for a selected element in the Elements panel.
After adding the folder, you'll have to give Chrome access to the folder.
Next, you need to map the network resource to the local resource.
After reloading the page, Chrome now loads the local resources for the mapped files. To make things simpler, Chrome only shows you the local resources (so you don't get confused on as to whether you are editing the local or the network resource). To save your changes, press CTRL + S when editing the file.
p.s.
You may have to open the mapped file(s) and start editing to get Chrome apply the local version (date 201604.12).
DevTools tech writer and developer advocate here.
Starting in Chrome 65, Local Overrides is a new, lightweight way to do this. This is a different feature than Workspaces.
Set up Overrides
Go to Sources panel.
Go to Overrides tab.
Click Select Folder For Overrides.
Select which directory you want to save your changes to.
At the top of your viewport, click Allow to give DevTools read and write access to the directory.
Make your changes. In the GIF below, you can see that the background:rosybrown change persists across page loads.
How overrides work
When you make a change in DevTools, DevTools saves the change to a modified copy of the file on your computer. When you reload the page, DevTools serves the modified file, rather than the network resource.
The difference between overrides and workspaces
Workspaces is designed to let you use DevTools as your IDE. It maps your repository code to the network code, using source maps. The real benefit is if you're minifying your code, or using code that needs to get transpiled, like SCSS, then the changes you make in DevTools (usually) get mapped back into your original source code. Overrides, on the other hand, let you modify and save any file on the web. It's a good solution if you just want to quickly experiment with changes, and save those changes across page loads.
New versions of Chrome have a feature called workspaces which addresses this issue. You can define which paths on your webserver correspond to which paths on your system, then edit and save with just ctrl-s.
See: http://www.html5rocks.com/en/tutorials/developertools/revolutions2013/
I know it is an old post, but I save it this way :
Go to Sources pane.
Click Show Navigator (to show the navigator pane on left).
Click the CSS file you want. (It will open in the editor, with all changes you made)
Right click on editor and Save your changes.
You can also see Local Modifications to see your revisions, very interesting feature.
Also work with scripts.
You're looking in the wrong section of "Resources".
It's not under "Local Storage", it's under "Frames":
The above screenshot shows a diff of the original styles against the new modifications made in the devtools. You can right-click the item in the left pane and save it back to disk.
Tincr Chrome extension is easier to install (no need to run node server) AND also comes with LiveReload like functionality out the box! Talk about bi-directional editing! :)
Tin.cr Website
Chrome Web Store Link
Andy's Blog Article
Now that Chrome 18 was released last week with the required APIs, I published my chrome extension in the Chrome web store. The extension automatically saves changes in CSS or JS in Developer tools into the local disk. Go check it out.
UPDATE 2019: As other answers are bit outdated, I'll add updated one here. In latest version there's no need to map the chrome folder to filesystem.
So, suppose I have a web folder containing HTML,CSS,JS files in desktop which i want to be updated when I make changes in chrome:=
1) You'd need a running local server like node etc, alternatively this vscode extension creates the server for you: live server VSCode extension, install it, run the server.
2) load the html page in chrome from running local server.
3) Open devTools->Sources->Filesystem->Add folder to workspace
4) Add the folder which is used in running local server. No additional mapping is required in latest chrome! Ta-da!
More on it Edit Files With Workspaces
Note that the changes made on the styles tab will NOT reflect on the filesystem files.
Instead you need to go to devtools->source->your_folder and then make your changes there and reload the page to see the effect.
As long as you haven't been sticking the CSS in element.style:
Go to a style you have added. There should be a link saying inspector-stylesheet:
Click on that, and it will open up all the CSS that you have added in the sources panel
Copy and paste it - yay!
If you have been using element.style:
You can just right-click on your HTML element, click Edit as HTML and then copy and paste the HTML with the inline styles.
FYI, If you're using inline styles or modifying the DOM directly (for instance adding an element), workspaces don't solve this problem. That's because the DOM is living in memory and there's not an actual file associated with the active state of the DOM.
For that, I like to take a "before" and "after" snapshot of the dom from the console:
copy(document.getElementsByTagName('html')[0].outerHTML)
Then I place it in a diff tool to see my changes.
Full article: https://medium.com/#theroccob/get-code-out-of-chrome-devtools-and-into-your-editor-defaf5651b4a
To answer the last part of your question about any extensions that can save changes, there is hotfix
It allows you to save changes from Chrome Dev Tools directly to GitHub. From there you can set up a post-receive hook on GitHub to automatically update your website.