How to disable CSS in Browser for testing purposes

后端 未结 16 1548
自闭症患者
自闭症患者 2020-11-28 23:05

Is there any way I can disable all external CSS in a browser (Firefox, Chrome...)?

When using slower internet connection, sometimes only the bare HTML is loaded by t

16条回答
  •  离开以前
    2020-11-28 23:25

    I tried in Chrome Developer tools and the method is valid only if the CSS are included as external files and it won't work for inline styles.

    Array.prototype.forEach.call(document.querySelectorAll('link'), (element)=>element.remove());
    

    Or

    var linkElements = document.querySelectorAll('link');
    Array.prototype.forEach.call(linkElements, (element)=>element.remove());
    

    Explanations

    1. document.querySelectorAll('link') gets all the link nodes. This will return array of DOM elements. Note that this is not Array object of javascript.
    2. Array.prototype.forEach.call(linkElements loops through the link elements
    3. element.remove() removes the element from the DOM

    Resulting in plain HTML page

提交回复
热议问题