osompress / simple-social-icons

Plugin: Simple Social Icons
62 stars 33 forks source link

Fix AMP validation error for svgxuse.js #96

Closed nickcernis closed 2 years ago

nickcernis commented 5 years ago

Bare script elements are not allowed by AMP, so our use of svgxuse.js results in a validation error on all sites using the plugin with AMP.

https://github.com/studiopress/simple-social-icons/blob/a9105323026d27b249b780ede7f79e4ca0c85da5/simple-social-icons.php#L487

Screenshot 2019-05-01 at 12 13 36

Options to solve this include:

  1. Remove svgxuse.js altogether. (IE 9, 10, 11 would fail to show social icons on both the non-AMP and AMP version of sites.)
  2. Load svgxuse.js only if AMP is not in use. (IE 9, 10, 11 would fail to show social icons on the AMP version of the site.)

Option two might be best for now given that IE 11 is still in the browser support list for many StudioPress themes, such as Genesis Sample, and IE 11 is not officially supported by AMP anyway: https://amp.dev/support/faq/supported-browsers

+if ( function_exists( 'genesis_is_amp' ) && ! genesis_is_amp() ) {
    wp_enqueue_script('svg-x-use', plugin_dir_url(__FILE__) . 'svgxuse.js', array(), '1.1.21' );
+}
dreamwhisper commented 5 years ago

@nickcernis I think option 2 is good. I've already tested that solution too :)

dreamwhisper commented 2 years ago

svgxuse.js was removed previously