PHP code example of commnetivity / purehtml

1. Go to this page and download the library: Download commnetivity/purehtml library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

commnetivity / purehtml example snippets




$buffer = new PureHTML();

$template = file_get_contents("template.html");

$html->scan($template);  // Every call to scan() will build up $buffer with seen JS and CSS assets.

$html = $buffer->scrub($template); // Scrub the template of JS and CSS assets

/* Load up your dynamic content via DOM (optional, you can also use use a string of HTML) */
ob_start();
echo "Hello, world. I am to be spliced into the html div container with the id of \"content\".";
echo '<link href="helloworld.css" />';
$content = ob_get_contents();

$domOfDynamic = new DOMDocument(); // Create DOM object
$domOfDynamic->loadHTML($content); // Load DOM object with content
$frag = $domOfDynamic->saveHTML(); // Save the DOM into a string.

/* Scan fragment for JS and CSS */
$buffer->scan($frag); // If you want the buffer to contain JS and CSS resources in the order they are collected, then you must call this on each new HTML fragment or template you want to 



our script ...