Skip to content

Instantly share code, notes, and snippets.

View Malvoz's full-sized avatar
:octocat:
Busy

Robert Linder Malvoz

:octocat:
Busy
  • Sweden
View GitHub Profile
@adactio
adactio / sharebutton.js
Last active April 13, 2024 19:22
A polyfill for `button type="share"`
// Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
// http://creativecommons.org/publicdomain/zero/1.0/
/* Use <button type="share"> in your HTML.
Include this JavaScript in a <script> element on the same page or in an external script.
The script checks for three ways of sharing:
1. Native support for <button type="share">.
2. Support for the JavaScript Web Share API.
3. A mailto: link.
This will share the current URL and page title.
@Malvoz
Malvoz / new-video-capabilities.md
Last active January 10, 2020 12:28
Use case(s) for expanded capabilities of the <video> element.

People have asked for extended capabilities of HTML videos, this Gist is used to showcase a somewhat niched use case that incorporates theoretical capabilities as suggested in the issues raised by others, as mentioned below.

Use case:
Autoplay a background-video only on screens larger than 1000px (where the user hasn't set a preference to reduce motion), if the user prefers reduced motion and/or is on a smaller device then show the poster image instead.

<!-- 1) -->
<video autoplay muted playsinline>
 
@koto
koto / example.js
Last active January 11, 2020 08:22
Support for custom types in Trusted Type policies.
// Custom types for https://github.com/WICG/trusted-types/
// Allow a given TT policy to create custom unspoofable TrustedFoo instances.
const installFoo = (policy, rule, policyFactory) => {
const creatorSymbol = Symbol();
const map = new WeakMap();
// Some more defensive coding tricks can be applied here
// See https://github.com/WICG/trusted-types/blob/master/src/trustedtypes.js for inspiration.
class TrustedFoo {
@dauwhe
dauwhe / toast.md
Last active May 30, 2020 01:51
Are Web Standards Toast?

Are Web Standards Toast?

I find myself in a tempest in a toaster. Yesterday I (and much of the web standards world) learned about two possible new HTML elements proposed by Google, std-toast and std-switch. I had no idea what “toast” meant in the context of the web, a problem shared my many other people. It turns out it’s a UI pattern, those little notices that pop up and then disappear without user interaction.

But wow, new HTML elements! This is the holy grail. In my part of the web we don’t even dream about new HTML elements. Oh, we’ve tried, but Hixie didn’t much care for footnote, WICG didn’t much care for list titles, and no one much cared about author. Just last week the author of the extensible web manifesto warned me to never expect new HTML elements, due to the difficulty of changing the parser.

But my concern wasn’t so much about the nature of the new elements, but of how we learned about them and what that says about how web standardization works. My [first tweet](https://twitter.com

@diego-betto
diego-betto / DOM-Ready.js
Created September 7, 2017 16:53 — forked from franzese/DOM-Ready.js
Vanilla JavaScript Document Ready
Document.prototype.ready = function(callback) {
if(callback && typeof callback === 'function') {
document.addEventListener("DOMContentLoaded", function() {
if(document.readyState === "interactive" || document.readyState === "complete") {
return callback();
}
});
}
};
@zcorpan
zcorpan / results-20160901-105718.csv
Created September 1, 2016 09:03
MIME types in httparchive:har.2016_08_01_chrome_requests where request has Accept: */*
mime_type num ratio
application/javascript 3420696 0.2854122203498058
text/javascript 2228020 0.18589904954540665
application/x-javascript 2119380 0.17683446630889488
text/html 794291 0.06627316718991329
623072 0.05198718709812103
font/woff2 380195 0.03172228666794548
text/xml 305008 0.025448917560769377
image/gif 299090 0.024955138072609614
application/json 249823 0.020844453036589494
@franzese
franzese / DOM-Ready.js
Created June 29, 2016 01:30
Vanilla JavaScript Document Ready
Document.prototype.ready = function(callback) {
if(callback && typeof callback === 'function') {
document.addEventListener("DOMContentLoaded", function() {
if(document.readyState === "interactive" || document.readyState === "complete") {
return callback();
}
});
}
};