Skip to content

Instantly share code, notes, and snippets.

View mxdvl's full-sized avatar
🧭
I love me an SVG

Max Duval mxdvl

🧭
I love me an SVG
View GitHub Profile
@mxdvl
mxdvl / non-blocking-document.createElement.html
Last active January 22, 2024 23:16 — forked from sndrs/non-blocking-document.write.html
Override document.createElement('script') to prevent 3rd parties injecting blocking scripts
<!DOCTYPE html>
<html>
<head>
<title>Prevent non-async script</title>
<script>
(function(Document) {
const trueCreate = document.createElement.bind(document);
Document.prototype.createElement = function(tag, options) {
const script = trueCreate(tag, options);
@mxdvl
mxdvl / CacheBustingKirbyValetDriver.php
Last active August 2, 2018 14:16 — forked from stidges/CacheBustingLaravelValetDriver.php
Rewrite filename-based cache busting URIs (e.g. jquery.1476809927.js) to the correct filename in Laravel Valet
<?php
class CacheBustingKirbyValetDriver extends KirbyValetDriver
{
public function isStaticFile($sitePath, $siteName, $uri)
{
$result = parent::isStaticFile($sitePath, $siteName, $uri);
if ($result !== false) {
return $result;
}
if (preg_match('/(.+)\.(?:\d+)\.(js|css|png|jpg|jpeg|gif|svg|mp3|mp4|ogg)$/i', $uri, $matches)) {