Custom JS breaks Editor

To convert all the dates from us-format into swiss-format, I use a custom JS. But using that code, breaks the Editor (not Design-mode, only Editor-mode; eg I can no longer add a new Item to a cms-collection… Editor just does not react on clicking on the add-button):

$(document).ready(function() {
$.getScript('', function() {

  $('div.dateus').each(function() {
    var d = $(this);
    var dOrg = d.text();
    var dParsed = Date.parse(dOrg);

    $.getScript('', function() {
      var dLong = dOrg;
      if (d.hasClass('datum-lang')) {
        var dLong = dParsed.toString('d. MMMM yyyy');
      } else if (d.hasClass('datum-wochentag')) {
        var dLong = dParsed.toString('dddd, d. MMMM yyyy');




Can anyone help me to fix this code, so that Editor still works?

1 Like