
http://cdn.image.com?src=[img src]&width=200&height=100 와 같은 Image CDN 사용
React.lazy와 Suspense를 사용하여 코드 스플리팅 가능import React, { Suspense, lazy } from "react";
import { Switch, Route } from "react-router-dom";
import "./App.css";
const ListPage = lazy(() => import("./pages/ListPage/index"));
const ViewPage = lazy(() => import("./pages/ViewPage/index"));
function App() {
return (
<div className="App">
<Suspense fallback={<div>로딩중.. </div>}>
<Switch>
<Route path="/" component={ListPage} exact />
<Route path="/view/:id" component={ViewPage} exact />
</Switch>
</Suspense>
</div>
);
}
export default App;
GZIP, Deflate와 같은 압축 방법을 사용하여 텍스트 파일 크기를 줄임remove-markdownuseMemo, useCallbackfunction removeSpecialCharacter(str) {
const removeCharacters = [
"#",
"_",
"*",
"~",
"&",
";",
"!",
"[",
"]",
"`",
">",
"\n",
"=",
"-",
];
let _str = str;
let i = 0,
j = 0;
for (i = 0; i < removeCharacters.length; i++) {
j = 0;
while (j < _str.length) {
if (_str[j] === removeCharacters[i]) {
_str = _str.substring(0, j).concat(_str.substring(j + 1));
continue;
}
j++;
}
}
return _str;
}
🔽🔽🔽
function removeSpecialCharacter(str) {
let _str = str.substring(0, 300);
_str = _str.replace(/[\#\_\*\~\&\;\!\[\]\`\>\n\=\-]/g, "");
return _str;
}