Schema App JavaScript Archives End-to-End Schema Markup and Knowledge Graph Solution for Enterprise SEO Teams. Wed, 23 Aug 2023 18:50:31 +0000 en-CA hourly 1 https://wordpress.org/?v=6.5.5 https://ezk8caoodod.exactdn.com/wp-content/uploads/2020/07/SA_Icon_Main_Orange.png?strip=all&lossy=1&resize=32%2C32&ssl=1 Schema App JavaScript Archives 32 32 Schema Markup Filtering Javascript Library https://www.schemaapp.com/schema-markup/schema-markup-filtering-javascript-library/ Wed, 10 Oct 2018 01:47:47 +0000 https://www.schemaapp.com/?p=6949 There are lots of times websites have schema markup added by the CMS or Theme that add disappointing markup. In order to disambiguate the data items on the page, or to control the main entity or change between rich snippets, or just clean up erroneous markup we have a couple of options. First, try to...

The post Schema Markup Filtering Javascript Library appeared first on Schema App Solutions.

]]>
There are lots of times websites have schema markup added by the CMS or Theme that add disappointing markup. In order to disambiguate the data items on the page, or to control the main entity or change between rich snippets, or just clean up erroneous markup we have a couple of options. First, try to alter the theme or CMS that’s producing, but failing that you can use JavaScript to inspect the page and remove the schema markup.

For JavaScript, we’ve published a JavaScript library https://github.com/SchemaApp/schema-filter that can help to handle different scenarios.

Among the options, the JS library can be setup to filter combinations of:
1. Schema Class List (defaults to All)
2. Schema Syntax RDFa, Microdata or JSON-LD (defaults to microdata)

If you have ideas for improvements we can use the GitHub repository features to make suggestions.  Below we’ve included some of the read.me file to give you an idea on how it works and options.

SchemaFilter

JavaScript Filter tool to remove Schema markup in JSON-LD, Microdata, or RDFa formats from webpages.

Usage

To the use the script import it using a script tag. We recommend using the CDN version of the script where possible.

// Using the CDN Version (Recommended)
<script src="https://cdn.schemaapp.com/javascript/schemaFilter.min.js"></script>

// Loading asyncronously 
<script async src="https://cdn.schemaapp.com/javascript/schemaFilter.min.js"></script>

// Or load it locally
<script src="schemaFilter.js"></script>

Modes of removal

Schema Filter supports the removal of JSON-LD, Microdata, and RDFa. This is done by calling the specific functions or through specifying them by name. Multiple calls to the function can be used to remove more than one format. Each command must be within a <script>…</script>.

  • JSON-LD SchemaFilter.remove([],'json-ld'); or SchemaFilter.removeJSONLD();
  • Microdata SchemaFilter.remove(); or SchemaFilter.removeMicroData();
  • RDFa SchemaFilter.remove([],'rdfa'); or SchemaFilter.removeRDFa();

Specifying specific Types

Specifying particular schema classes is done through passing an array to the remove function. If all classes are to be removed then the array may be left empty ([]), or passed in as null.

// This will remove all Event and Organization types on Microdata
<script>SchemaFilter.remove(['Event', 'Organization']);</script>

// This will remove LocalBusiness, Organization, and WebSite classes in a JSON-LD format. 
<script>SchemaFilter.remove(['LocalBusiness', 'Organization', 'WebSite'], 'json-ld');</script>

// Remove all classes of rdfa (notice the empty array).
<script>SchemaFilter.remove([],'rdfa');</script>

// Remove all Organizations of RDFa
<script>SchemaFilter.remove(['Organization'], 'rdfa');</script>

// Remove all classes of JSON-LD (notice we can also use null for the array).
<script>SchemaFilter.remove(null,'json-ld');</script>

Running the script on your page

Once the script is imported you may the run script in another block of JavaScript. The script should be run when the document is ready or after another event that injects Schema Markup into the page. If the markup is embedded in the source you may run when the document is loaded as shown below.

<script>SchemaFilter.remove(null, 'json-ld');</script>

If you want to alter the event in which the code is loaded you can specify the string event value into the onLoad property of the SchemaFilter.

<script>
SchemaFilter.onLoad = 'SomeEventHere'; // the default value
SchemaFilter.remove();
</script>

At Schema App, we look at schema markup as an iterative process. Through enhanced analytics and content recommendations, we help our customers maximize their results through structured data. If you need help getting started, get in touch today!

Start reaching your online business goals with structured data.

 

The post Schema Markup Filtering Javascript Library appeared first on Schema App Solutions.

]]>