Saving CSS and JavaScript changes made in the Safari Web Inspector
Q: I just made a bunch of changes to my CSS and JavaScript in the Safari Web Inspector. Is there any way to save them?
You're probably tweaking your CSS values in the right sidebar of the Web Inspector, under the Rules pane. The DOM Tree view is likely showing in the center panel, like so:
After you've changed a style, click on the name of your CSS file in the Resources list on the left, or click on this file name next to the CSS style you were just editing:
This will switch the center panel from the DOM Tree to the Source Editor view. The changes you have previously made under the Rules panel in the right sidebar will be reflected in the source view. Here's what I see while making changes to the subtitle color and background color:
Then after I click the CSS file name, I see those changes reflected in the Source Editor view:
Press cmd-s to save. A Save panel will come up, and it will ask you if you want to replace the CSS file that's already there. You do!
From this point on you can press cmd-s and the changes will be saved silently, without the Save panel prompt. If you open a new window and begin inspecting, changing, and saving again, you'll get that initial Save panel prompt again.
The same thing works for JavaScript changes. Switch the center panel to the Source Editor view by clicking on a JavaScript file name, make changes to your source code, then press cmd-s to save.
Here's a set of files to test with, if you'd like to try this out.
Bonus: Keep your CSS or JS file open in a text editor that live updates changes from disk, while working and saving in the Web Inspector. That way, if you save in the Web Inspector but realize you made a mistake, you can switch to your text editor and Undo (press cmd-z) to easily get back to the previous state.
// <![CDATA[ !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs'); // ]]>