Skip to content

Instantly share code, notes, and snippets.

@odlp
Created January 30, 2017 17:02
Show Gist options
  • Save odlp/23efb0d42a97056d46917e5fcbbc9c87 to your computer and use it in GitHub Desktop.
Save odlp/23efb0d42a97056d46917e5fcbbc9c87 to your computer and use it in GitHub Desktop.
Detect modernizr - Is it being used in the project?
# Determine the feature list from the custom build URL in the source file, e.g.:
# Build: http://modernizr.com/download/#-fontface-backgroundsize-borderimage-borderradius-boxshadow-flexbox-flexboxlegacy-hsla-multiplebgs-opacity-rgba-textshadow-cssanimations-csscolumns-generatedcontent-cssgradients-cssreflections-csstransforms-csstransforms3d-csstransitions-applicationcache-canvas-canvastext-draganddrop-hashchange-history-audio-video-indexeddb-input-inputtypes-localstorage-postmessage-sessionstorage-websockets-websqldatabase-webworkers-geolocation-inlinesvg-smil-svg-svgclippaths-touch-webgl-cssclasses-teststyles-testprop-testallprops-hasevent-prefixes-domprefixes-load
has_features = [
"fontface",
"backgroundsize",
"borderimage",
"borderradius",
"boxshadow",
"flexbox",
"flexboxlegacy",
"hsla",
"multiplebgs",
"opacity",
"rgba",
"textshadow",
"cssanimations",
"csscolumns",
"generatedcontent",
"cssgradients",
"cssreflections",
"csstransforms",
"csstransforms3d",
"csstransitions",
"applicationcache",
"canvas",
"canvastext",
"draganddrop",
"hashchange",
"history",
"audio",
"video",
"indexeddb",
"input",
"inputtypes",
"localstorage",
"postmessage",
"sessionstorage",
"websockets",
"websqldatabase",
"webworkers",
"geolocation",
"inlinesvg",
"smil",
"svg",
"svgclippaths",
"touch",
"webgl",
"cssclasses",
"teststyles",
"testprop",
"testallprops",
"hasevent",
"prefixes",
"domprefixes",
"load",
]
no_features = has_features.map do |feature|
"no-#{feature}"
end
(has_features + no_features).each do |feature|
as_class = "\\\.#{feature}"
result = `grep "#{as_class}" -RI app`
if !result.empty?
File.write("./tmp/#{feature}", result)
else
puts "No matches for: #{feature}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment