include tinymce only if a user is logged into the site

For google page speed i had an issue when every page was loading tinymce, which is quite a large script.

I only actually use this script when editing pages, so this is the change i made to only insert it into the template if a user is logged into the site. 

This was related to : Google Page Speed Cleanup and Testing

PHP

// global.php
$tiny_mce_js = "";
if(isset($_SESSION["global_login"])) {
  $tiny_mce_js = '<script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.8.4/tinymce.min.js" integrity="sha256-rjy8f5xTyKOb6CxACEd6Vc99uhhjTKuqmTMrZ7TbdOA=" crossorigin="anonymous"></script>';
}
$template->set("tiny_mce_js",$tiny_mce_js);

/* index.html (template) */
replace the script with 
[ @ tiny_mce_js]

Other Items in php
Related Search Terms
Page Views

This page has been viewed 95 times.

Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.

âĪðŸ‘Đ‍ðŸ’ŧðŸ•đ

Random Quote
Even if you fall on your face, you're still moving forward.
Victor Kiam