Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to remove the style tags from the header section

I am using angular js and deployed a site, In the head part of my website there are a lot of style tags are coming in the console like the below image, I attached a snap of my website console. I don't know where those tags are coming from and how can I remove those style tags from the head of the website

enter image description here

like image 578
Midhunsai Avatar asked Apr 27 '17 06:04

Midhunsai


Video Answer


3 Answers

As of my understanding, you are using Angular Material Design and it is responsible for adding the style tags in your head section. It all happens under the hood, you can follow this link to know more. I think you no need to worry about removing this style tags and all because it came as functionality. Angular Material Design dynamically inject this style tags for theming purpose.

Reference: https://material.angularjs.org/latest/Theming/05_under_the_hood

Thank you.

EDIT

If you don't want to generate themes by default then you can use

$mdThemingProvider.generateThemesOnDemand(true);

Example:

    angular.module('myApp', ['ngMaterial'])
    .config(function($mdThemingProvider, $provide) {
      //disable theme generation
      $mdThemingProvider.generateThemesOnDemand(true);
      $provide.value('themeProvider', $mdThemingProvider);

    })
    .run(['themeProvider', '$mdTheming', function(themeProvider, $mdTheming) {
      //create new theme
      themeProvider.theme('default')
      .primaryPalette('pink')
      .accentPalette('orange')
      .backgroundPalette('yellow');

      //reload the theme
      $mdTheming.generateTheme('default');

      //optional - set the default to this new theme
      themeProvider.setDefaultTheme('default');
    }]);

Reference: https://material.angularjs.org/latest/Theming/04_multiple_themes

like image 91
Arpit Kumar Avatar answered Oct 19 '22 14:10

Arpit Kumar


If you want to remove all the style tags :

var st = document.getElementsByTagName('style');

and add a loop to remove all of them.

for(i = 0 ; i < st.length ; i++){

    st[i].parentNode.removeChild(st[i]);

}
like image 36
bhansa Avatar answered Oct 19 '22 12:10

bhansa


Please Try with below JQuery code

$('style[md-theme-style]').remove();
like image 29
parveen-kaushik Avatar answered Oct 19 '22 12:10

parveen-kaushik