Skip to content

Commit

Permalink
fix(perf): lazy load sanitize-html
Browse files Browse the repository at this point in the history
  • Loading branch information
ichim-david committed May 31, 2024
1 parent b7564c9 commit dc57b48
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Utils/FormattedValue.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react';
import isObject from 'lodash/isObject';
import loadable from '@loadable/component';
import cx from 'classnames';
import sanitizeHtml from 'sanitize-html';
import { CountUp } from '@eeacms/countup';
import { UniversalLink } from '@plone/volto/components';
import { isUrl } from '@plone/volto/helpers';
Expand All @@ -23,6 +22,14 @@ const AnimatedCounter = ({ originalValue }) => {
);
};

const sanitizeHtml = async (value, allowedAttributes) => {
const sanitized = await import('sanitize-html');
const result = sanitized.default(value, {
...allowedAttributes,
});
return result;
};

const FormattedValue = ({
linkTemplate,
textTemplate,
Expand Down Expand Up @@ -65,7 +72,6 @@ const FormattedValue = ({
href: linkValue,
}
: {};

const html =
isLink && isObject(link) && link.title
? link.title
Expand Down

0 comments on commit dc57b48

Please sign in to comment.