As of Summer '17 with locker service and with "Enable Stricter CSP for Lightning Components" Enabled it will no longer be supported. the documentation lists supported tags and attributes as well as an IMPORTANT note.
Important: With the "Enable Stricter CSP for Lightning Components in
Communities" critical update, you have control over whether to enforce
stricter CSP. When stricter CSP is activated, some of your existing
head markup may not work correctly. Test your markup in your sandbox
or DE orgs first before activating in live orgs in a future release.
For security purposes, we restrict the tags, attributes, and values
allowed in the head markup of your pages
<base>
Allowed Attributes:
href, target
<link>
Allowed Attributes:
as, charset, crossorigin, disabled, href,
hreflang, id, import, integrity, media, rel, relList, rev, sheet,
sizes, target, title, type
**For rel, allowed values are alternate:
apple-touch-icon, apple-touch-icon-
precomposed, apple-touch-startup-image, author, bookmark, external,
help, icon, license, manifest, mask-icon, next, nofollow, noopener,
noreferrer, pingback, prefetch, preload, prev, search, shortcut icon,
stylesheet, and tag.
<meta>
Allowed Attributes:
charset, content, http-equiv,2 name, scheme
**For http-equiv, allowed values are cleartype, content-type,
content-language, and default-style.
<title>
None allowed
You will have to monitor and check for critical updates and decide which ones to enable/disable.
Best Answer
added based on comments
You should not use direct
#
(Id selector) and.
(class selector) selectors in jquery (or any other library) as that will cross the component boundary. You should instead use$(component.find('initid').getElement())
which will respect component boundary.Once the library is loaded
$
is available throughout. Also there is no need ofonready
as you are already invoking the function onafterScriptsLoaded
.Below is the sample script:
COMPONENT:
CONTROLLER js:
Old answer
I just tested in my org with below code:
COMPONENT file:
CONTROLLER js:
And got below log:
This means it is working in community - even when I login as community user.