Remove JS from Print CSS

So, I am working on the site, and I just do the finishing touches, I used a lot of javascript, and it continues to show in the print version of the site ... even if I comment on it I just wondered if anyone could know how easy it is to delete javascript from the print version of the site, and if that helps, the site is written in PHP.

Thanks for reading.

EDIT: Javascript itself does not work, it directly shows the code itself, and does not run it, and, if possible, I would like to completely remove all javascript elements.

+3
source share
1 answer

Can you try this PHP code:

$str = file_get_contents("http://stackoverflow.com");
$pattern = '#\<script.*?\>(.*?)\<\/script\>#si'; 
$str = preg_replace($pattern, '', $str);
die($str);

It removes all script tags from within. Now you can print it ...

+1
source

All Articles