Due to big time lags because of a remote database, I am working on on a PHP/cron script fetching webpages from the CMS and saving them as static webpages. Then serving the static webpages to visitors. I have also decided to try and minify the resultant html file before saving it. All the above works pretty well (fetch, remove comments, minify, save), BUT swipe.js stops working.
My basic code is:
// get the webpage from CMS
$contents = file_get_contents($cms_url);
// remove comments
$contents = preg_replace('/<!--(?!\s*(?:\[if [^\]]+]|<!|>))(?:(?!-->).)*-->/Uis', '', $contents);
// minify
$contents = preg_replace('/^\s+|\n|\r|\s+$/m', '', $contents);
// delete old cached copy
unlink($web_url);
// save new copy
file_put_contents($web_url , $contents);
After a lot of experimenting, I have come to the conclusion that swipe.js issue begins after removing the newline character (\n).
Has anyone dealt with this issue before? Is it a jQuery issue with the way they look for children as that seems to be the way swipe determines the correct divs? Or is it a swipe.js issue? Or is it the way I am removing the newline character? Or??
additional notes ----
Did some more experimenting with the minifaction aspect by using third party html minification tools and the same issue occurs with those minified files. So my PHP code is not the contributing factor.
It seems to be an issue with either jQuery or Swipe.js, as once the new line characters are removed the targeted content wrapper div isn't being modified.
Swipe.js is in an external file so is not be modified by my minifaction on the html files.
None of the other jQuery functions on the page are being effected by the minification.